﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Commandparser.Common
{
    class Method : IPropertyObject
    {

        public Function ToFunction(string s)
        {
            var f = new Function {Name = s.Split('(')[0]};

            string @params = Middle(s, "(", ")");

            if (@params.Contains(","))
            {
                f.Params = @params.Split(',');
            }
            else
            {
                f.Params = new string[] { @params };
            }

            return f;
        }

        
        public bool isFunction(string c)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(c, "[a-z0-9_\\-]+\\((.*?\\)).*");
        }

    }
}
